//
//  FileUtil.swift
//  firstProject
//
//  Created by 张彦辉 on 2017/5/3.
//  Copyright © 2017年 张彦辉. All rights reserved.
//

import Foundation

struct FileUtil {
    // MARK: -检查文件是否存在
    static func exists(path: String) ->Bool{
        let fileManager = FileManager.default
        return fileManager.fileExists(atPath: path)
    }
    
    // MARK: - 创建文件
    static func createPath(filePath: String) -> Bool{
        let fileManager = FileManager.default
        return fileManager.createFile(atPath: filePath, contents: nil, attributes: nil)
    }
    
    // MARK: - 创建目录
    static func createPath(directoryPath: String) -> Bool{
        let fileManager = FileManager.default
        var fals: Bool = true
        do {
            try fileManager.createDirectory(atPath: directoryPath, withIntermediateDirectories: false, attributes: nil)
        } catch {
            fals = false
        }
        return fals
    }
    
    // MARK: - 删除目录
    static func remove(path: String) -> Bool{
        let fileManager = FileManager.default
        var fals: Bool = true
        do {
            try fileManager.removeItem(atPath: path)
        } catch  {
            fals = false
        }
        return fals
    }
}
